package com.autism.day02.redpackage;

import java.util.ArrayList;

public class Manage extends User {
    public Manage() {

    }

    public Manage(double amount, String name) {
        super(amount, name);
    }

    public ArrayList<Double> send(double amount, int count) {
        //需要一个集合用来存储若干个红包金额
        ArrayList<Double> redList = new ArrayList<>();

        //获取总金额
        double leftMoney = super.getAmount();
        if (amount > leftMoney) {
            System.out.println("余额不足");
            return redList;
        }

        //扣钱
        super.setAmount(leftMoney - amount);

        //发红包
        double avg = amount / count;
        for (int i = 0; i < count; i++) {
            redList.add(avg);
        }

        return redList;
    }
}
